<%@ page import="Bean.BookInfoEntity" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%--
  Created by IntelliJ IDEA.
  User: 高金磊
  Date: 2021/4/16
  Time: 9:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>新增文档 - bootstrap中文后台管理系统模板</title>
    <link rel="icon" href="<%=basePath%>favicon.ico" type="image/ico">
    <meta name="keywords" content="后台模板,后台管理系统,HTML模板">
    <meta name="description" content="基于Bootstrap的后台管理系统模板">
    <link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=basePath%>css/fonts.css" rel="stylesheet">
    <!--标签插件-->
    <link rel="stylesheet" href="<%=basePath%>js/jquery-tags-input/jquery.tagsinput.min.css">
    <link href="<%=basePath%>css/style.css" rel="stylesheet">
    <style>

        #textarea {
            display: block;
            margin:0 auto;
            overflow: hidden;
            width: 550px;
            font-size: 14px;
            height: 18px;
            line-height: 24px;
            padding:2px;
        }
        textarea {
            outline: 0 none;
            border-color: rgba(82, 168, 236, 0.8);
            box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);
        }

    </style>
</head>
<body>
<button class="btn btn-link" onclick="window.history.back()">返回上一级</button>
<%--<s:form action="UpdateBookInfo" method="POST" enctype="multipart/form-data">--%>
    <%--<s:iterator value="#request.bookInfoEntity" var="book">--%>
        <%--<input name="modify_id" type="hidden" value=<s:property value="#request.bookInfoEntity.id"/>>--%>
    <%--<span>书名：</span>--%>
        <%--<span><input name="book_name" value=<s:property value="#request.bookInfoEntity.book_name"/>></span><br>--%>
    <%--<span>作者</span><br>--%>
        <%--<span><input name="book_Author" value=<s:property value="#request.bookInfoEntity.book_Author"/>></span><br>--%>
    <%--<span>简介</span><br>--%>
        <%--<span><input name="book_Info"  value=<s:property value="#request.bookInfoEntity.book_Info"/>></span><br>--%>
    <%--<span>标签1</span><br>--%>
        <%--<span><input name="book_tag1"  value=<s:property value="#request.bookInfoEntity.book_tag1"/>></span><br>--%>
    <%--<span>标签2</span><br>--%>
        <%--<span><input name="book_tag2"  value=<s:property value="#request.bookInfoEntity.book_tag2"/>></span><br>--%>
    <%--<span>图书总量</span><br>--%>
        <%--<span><input name="sum" value=<s:property value="#request.bookInfoEntity.sum"/>></span><br>--%>
        <%--<span>图书已用量</span><br>--%>
        <%--<span><input name="used" value=<s:property value="#request.bookInfoEntity.used"/>></span><br>--%>
    <%--<span>图书照片(填写将修改,不填写保持默认)</span><br>--%>
    <%--<s:file type="file" name="book_picture_File" value="选择上传的文件"/><br>--%>
        <%--<img style="width: 50px" src=<%=request.getContextPath()+"/"+"cache/booksInfo/"%><s:property value="#request.bookInfoEntity.book_name"/>.jpg >--%>
    <%--<br><br>--%>
    <%--<span style="font-size: 15px; color: red"> <s:actionerror/></span><br><br><br>--%>
    <%--<span style="font-size: 13px; color: green"> <%=request.getSession().getAttribute("message")==null?"":request.getSession().getAttribute("message")%> </span><br><br><br>--%>
    <%--<input type="submit" value="提交" formaction="UpdateBookInfo"/>--%>
        <%--<input type="submit" value="删除" formaction="BookInfoManage_Del"/>--%>
    <%--</s:iterator>--%>
<%--</s:form>--%>

<!--页面主要内容-->
    <s:form  method="POST" class="row" enctype="multipart/form-data">
    <div  class="col-md-12"  >
        <div class="row" style="margin-top:5px;">
            <div class="col-lg-12">
                <div class="card">
                    <h4>修改图书信息</h4>
                    <div class="card-body">


                            <%--为了便于回传修正错误的信息下面不适用s标签来取数据--%>
                            <input name="modify_id" type="hidden" value=<s:property value="#request.bookInfoEntity.id"/>>
                            <div class="form-group col-md-12">
                                <label for="title">ID</label>
                                <input type="number" disabled="disabled" class="form-control" value=<s:property value="#request.bookInfoEntity.id"/>  >
                            </div>
                            <div class="form-group col-md-12">
                                <label for="title">书名</label>
                                <input type="text" class="form-control" id="title" name="book_name"  value=<s:property value="#request.bookInfoEntity.book_name"/>  >
                            </div>
                            <div class="form-group col-md-12">
                                <label for="seo_keywords">作者</label>
                                <input class="form-control" id="seo_keywords" name="book_Author" type="text" value=<s:property value="#request.bookInfoEntity.book_Author"/> />
                            </div>
                            <div class="form-group col-md-12">
                                <label for="seo_keywords">简介</label>
                                <textarea id="textarea" name="book_Info"  style="width: 100%;background-color: rgba(0,0,0,0);"><s:property value="#request.bookInfoEntity.book_Info"/></textarea>

                            </div>
                            <div class="form-group col-md-12">
                                <label for="seo_description">标签1</label>
                                <input class="form-control" id="seo_description" name="book_tag1" type="text" value=<s:property value="#request.bookInfoEntity.book_tag1"/> />
                            </div>

                            <div class="form-group col-md-12">
                                <label for="seo_keywords">标签2</label>
                                <input class="form-control" name="book_tag2" type="text" value=<s:property value="#request.bookInfoEntity.book_tag2"/> />
                            </div>
                            <div class="form-group col-md-12">
                                <label for="seo_keywords">图书总量</label>
                                <input min="1" max="100000" class="form-control"  name="sum" type="number" value=<s:property value="#request.bookInfoEntity.sum"/> />
                            </div>
                            <div class="form-group col-md-12">
                                <label for="seo_keywords">图书照片<small style="font-size: 10px">选填(填写以更新)</small></label>
                                <input type="file" name="book_picture_File" value="选择上传的文件" onchange="newfile(this)" />
                                <img width="100" src=<%=request.getContextPath()+"/"+"cache/booksInfo/"%><s:property value="#request.bookInfoEntity.book_name"/>.jpg  id="img-id" alt="000" />
                                <script>
                                    function newfile(obj) {
                                        var reader = new FileReader();	// 实例化一个FileReader对象，用于读取文件
                                        //获取到img标签的对象
                                        var img = document.getElementById("img-id");
                                        //读取File对象的数据
                                        reader.onload = function(evt){
                                            img.src = evt.target.result;
                                        }
                                        reader.readAsDataURL(obj.files[0]);
                                    }
                                </script>
                            </div>
                            <div class="card-body">

                                <a href="">浏览量 <span class="badge"><s:property value="#request.bookInfoEntity.vister"/> </span></a>
                                <a href="">已借出<span class="badge"><s:property value="#request.bookInfoEntity.used"/></span></a>
                                <a href="">评论量<span class="badge"><s:property value="#request.bookInfoEntity.getBookCommentEntitys().size()"/></span></a>

                                    <span style="font-size: 9px; color: red"> <s:actionerror/></span><br><br><br>
                                    <span style="font-size: 15px; color: #28da10"> <s:actionmessage/></span><br><br><br>
                                    <button type="submit" class="btn btn-label btn-primary" formaction="UpdateBookInfo" >
                                        <label class="ftsucai-gou-2">
                                        </label>
                                        确 定
                                    </button>
                                    <button type="submit" class="btn btn-label btn-warning" formaction="ShowBookInfoManage">
                                        <label class="ftsucai-del-1">
                                        </label>
                                        放弃修改
                                    </button>
                            </div>

                    </div>
                </div>
            </div>

        </div>

    </div >
        <div class="col-md-12">
            <div class="card">

                <div class="container-fluid" style="margin-bottom:15px;">

                <div class="row" style="margin-top:15px;">
                    <div class="col-lg-16">
                        <div class="card">
                            <h4>本书订单动态(最近10条)</h4>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-striped table-hover">
                                        <thead>
                                        <tr>
                                            <th >订单号</th>
                                            <th>用户名</th>
                                            <th>图书名称</th>
                                            <th>下单日期</th>
                                            <th>借阅天数</th>
                                            <th>状态</th>
                                            <th>订单情况</th>
                                        </tr>
                                        </thead>
                                        <tbody>

                                        <s:iterator value="#request.loanBookLogRecords" var="data">
                                            <tr>
                                                <td><s:property value="#data[0]"/> </td>
                                                <td><a class="submenuitem" href="" data-id="link552" data-index="552"><s:property value="#data[1]"/> </a></td>
                                                <td><s:property value="#data[2]"/> </td>
                                                <td><s:property value="#data[3]"/> </td>
                                                <td><s:property value="#data[4]"/> </td>
                                                <td><span class="label label-info"><s:property value="#data[5]"/> </span></td>
                                                <td>
                                                    <div class="progress progress-striped progress-sm">
                                                        <div class="progress-bar progress-bar-success" style="width: <s:property value="#data[6]"/>%;"></div>
                                                    </div>
                                                </td>
                                            </tr>
                                        </s:iterator>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </div>
        <div class="col-md-12">
            <div class="card">

                <div class="container-fluid" style="margin-bottom:15px;">

                    <div class="row" style="  margin-top:15px;">
                        <div class="col-lg-16">
                            <div class="card">
                                <h4>本书最新评论(最近10条)</h4>
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-hover">
                                            <thead>
                                            <tr>
                                                <th >用户名</th>
                                                <th>时间</th>
                                                <th>内容</th>

                                            </tr>
                                            </thead>
                                            <tbody>

                                            <s:iterator value="#request.book_recomments" var="data">
                                                <tr>
                                                    <td><s:property value="#data[0]"/> </td>
                                                    <td><s:property value="#data[1]"/> </td>
                                                    <td><s:property value="#data[2]"/> </td>
                                                </tr>
                                            </s:iterator>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    <%--最新评论--%>


        <%--图书信息修改记录--%>



<!--End 页面主要内容-->
</s:form>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/bootstrap.js"></script>
<script type="text/javascript" src="<%=basePath%>js/perfect-scrollbar.min.js"></script>
<!--标签插件-->
<script src="<%=basePath%>js/jquery-tags-input/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<%=basePath%>js/main.min.js"></script>

<script>
    var autoTextarea = function (elem, extra, maxHeight) {
        extra = extra || 0;
        var isFirefox = !!document.getBoxObjectFor || 'mozInnerScreenX' in window,
            isOpera = !!window.opera && !!window.opera.toString().indexOf('Opera'),
            addEvent = function (type, callback) {
                elem.addEventListener ?
                    elem.addEventListener(type, callback, false) :
                    elem.attachEvent('on' + type, callback);
            },
            getStyle = elem.currentStyle ? function (name) {
                var val = elem.currentStyle[name];

                if (name === 'height' && val.search(/px/i) !== 1) {
                    var rect = elem.getBoundingClientRect();
                    return rect.bottom - rect.top -
                        parseFloat(getStyle('paddingTop')) -
                        parseFloat(getStyle('paddingBottom')) + 'px';
                };

                return val;
            } : function (name) {
                return getComputedStyle(elem, null)[name];
            },
            minHeight = parseFloat(getStyle('height'));

        elem.style.resize = 'none';

        var change = function () {
            var scrollTop, height,
                padding = 0,
                style = elem.style;

            if (elem._length === elem.value.length) return;
            elem._length = elem.value.length;

            if (!isFirefox && !isOpera) {
                padding = parseInt(getStyle('paddingTop')) + parseInt(getStyle('paddingBottom'));
            };
            scrollTop = document.body.scrollTop || document.documentElement.scrollTop;

            elem.style.height = minHeight + 'px';
            if (elem.scrollHeight > minHeight) {
                if (maxHeight && elem.scrollHeight > maxHeight) {
                    height = maxHeight - padding;
                    style.overflowY = 'auto';
                } else {
                    height = elem.scrollHeight - padding;
                    style.overflowY = 'hidden';
                };
                style.height = height + extra + 'px';
                scrollTop += parseInt(style.height) - elem.currHeight;
                document.body.scrollTop = scrollTop;
                document.documentElement.scrollTop = scrollTop;
                elem.currHeight = parseInt(style.height);
            };
        };

        addEvent('propertychange', change);
        addEvent('input', change);
        addEvent('focus', change);
        change();
    };

    var text = document.getElementById("textarea");
    autoTextarea(text);// 调用
</script>
</body>
</html>
